<template>
    <view>
		<form @submit="saveAddress">
			<view class="weui_cells_title">
				<view class="weui_cell">
					<view class="weui_title">收货人</view>
					<input class="weui_input" name="consignee" placeholder="请输入收货人真实姓名" />
				</view>

				<view class="weui_cell">
					<view class="weui_title">手机号</view>
					<input class="weui_input" name="mobile" placeholder="请输入收货人手机号" />
				</view>

				<view class="weui_cell">
					<view class="weui_title">省市(区/县)</view>
					<input class="weui_input" name="address" placeholder="请输入收货人地址" />
				</view>

				<view class="weui_cell">
					<view class="weui_title">详细地址</view>
					<input class="weui_input" name="detailAddress" placeholder="请输入收货人详情地址" />
				</view>

				<view class="weui_btn_wrap">
					
					<button class="weui_btn" form-type="reset">重置</button>
					<button class="weui_btn" form-type="submit">保存</button>

				</view>

			</view>
		</form>
	</view>	
</template>

<script>

	export default {
       
		methods:{
			saveAddress(e){
				let newAddress = e.detail.value;

				let addressList = uni.getStorageSync('addressList')||[];

				addressList.push(newAddress);
				
				uni.setStorageSync('addressList',addressList)

				uni.showToast({title:'添加成功',duration:2000,success:()=>{
					setTimeout(()=>{
						uni.navigateTo({url:'/pages/get_userinfo/index'})
					},2000)
				}})

			}
		}
	}
</script>

<style lang="scss">
	.weui_cells_title{
		.weui_cell{
			border: 1rpx solid #ccc;
			padding: 30rpx;
			display: flex;
			.weui_title{
				flex: 1;
			}
			.weui_input{
				flex: 3;
			}
		}
		.weui_btn_wrap{
			display: flex;
			.weui_btn{
				margin-top: 50rpx;
				width: 30%;
				background-color: var(--themeColor);
				color: #fff;
				border-radius: 10rpx;
			}
		}
	
	}
</style>